Repository navigation
feat(payment): Mayar jadi satu-satunya payment gateway (API key, Web Token, webhook) - #3
Merged
Merged
Conversation
…d webhook
- Remove DOKU (provider, /api/webhooks/doku, env, scripts). Legacy
PAYMENT_GATEWAY_PROVIDER=doku / SUBSCRIPTION_PAYMENT_MODE=doku_* still boot,
read as Mayar with a system-status warning.
- Webhook auth: MAYAR_WEBHOOK_TOKEN (Mayar dashboard "Web Token") via the
X-Callback-Token header, ?token= on the URL, or an HMAC of the raw body.
The API key is never accepted as a webhook token.
- Never trust a "paid" webhook on its own: re-read GET /hl/v2/payments/{id}
with the reference stored at creation and require a matching amount before
settling POS orders or activating subscriptions. Non-payment events and
orders KaffePOS does not know are acknowledged with 200.
- Online payment only opens when both MAYAR_API_KEY and MAYAR_WEBHOOK_TOKEN
are set. Sandbox host defaults to api.mayar.io (current Mayar docs).
- Redact ?token= from request logs and alerts.
- Add backend/scripts/mayar-connect.mjs (check key, register + test webhook),
scripts/smoke-local-mayar.mjs (local end-to-end run with a fake Mayar API)
and docs/engineering/MAYAR_INTEGRATION_GUIDE.md. Update env templates,
release checks and staging scripts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011vndxq8hQ8FPSGhexsE9Tz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ringkasan
Mayar (Headless API v2) sekarang jadi satu-satunya payment gateway untuk checkout POS online dan langganan. DOKU dihapus.
Perubahan
/api/webhooks/doku, envDOKU_*, dan script smoke DOKU. Deployment yang masih berisiPAYMENT_GATEWAY_PROVIDER=doku/SUBSCRIPTION_PAYMENT_MODE=doku_*tetap bisa boot. Nilainya dibaca sebagai Mayar dan muncul peringatan di/api/admin/system-status.MAYAR_API_KEY) dipakai untukPOST /hl/v2/payments/createdanGET /hl/v2/payments/{id}.MAYAR_WEBHOOK_TOKEN): webhook wajib membawa token dari dashboard Mayar di headerX-Callback-Token.?token=di URL atau HMAC body juga diterima. API key tidak pernah diterima sebagai token webhook.https://api.mayar.io(sesuai docs Mayar terbaru). Akun lamaweb.mayar.clubbisa setMAYAR_SANDBOX_BASE_URL=https://api.mayar.club.?token=disamarkan di log request/alert.backend/scripts/mayar-connect.mjs(cek key, daftarkan + tes URL webhook),scripts/smoke-local-mayar.mjs(uji end-to-end lokal dengan Mayar tiruan),docs/engineering/MAYAR_INTEGRATION_GUIDE.md.release:verify-config, dan script staging diperbarui ke Mayar.Setelah merge
PAYMENT_GATEWAY_PROVIDER=mayar,MAYAR_ENVIRONMENT,MAYAR_API_KEY,MAYAR_WEBHOOK_TOKEN(Web Token). HapusDOKU_*, lalu redeploy.https://api.kaffepos.my.id/api/webhooks/mayar, atau jalankannode scripts/mayar-connect.mjs --registerdi container backend.node scripts/mayar-connect.mjs. Kalau semua ✓, Mayar sudah terhubung.Pengujian
vite buildOK.npm run smoke:local:mayardengan Postgres lokal + Mayar tiruan: semua lulus. Yang diuji: order QRIS POS, webhook tanpa/salah token (401), webhook "paid" palsu saat Mayar belum lunas (409), pelunasan sekali + duplikat diabaikan, aktivasi langganan, cek status manual idempoten,mayar-connect --register, dan token tidak muncul di log.Generated by Claude Code